<?php

namespace App\Http\Controllers;

use App\Models\LogSms;
use Illuminate\Http\Request;

class LogSmsController extends CommonController
{

    /**
     * 获取列表
     */
    public function getIndex()
    {
        $lists = LogSms::orderBy('created_at', 'desc')->paginate(10);
        return view('logsms.index')->with("lists", $lists);
    }


    /**
     * 执行一个搜索
     */
    public function search(Request $request)
    {
        $data = $request->input();
        $sql = logSms::orderBy('created_at', 'desc');

        if (isset($data['content']) && $data['content'] != '') {
            $sql->where('content', 'like', '%' . trim($data['content']) . '%');
        }

        if (isset($data['phone']) && $data['phone'] != '') {
            $sql->where('phone', 'like', '%' . trim($data['phone']) . '%');
        }

        $lists = $sql->paginate(10);

        return view('logsms.search')->with('lists', $lists)
            ->with('content', trim($data['content']))
            ->with('phone', trim($data['phone']))
            ->with('actions', $this->actions);
    }


}
